package com.itboye.ihomebank.presenter;

import java.util.Observer;

import com.itboye.ihomebank.base.BasePresenter;
import com.itboye.ihomebank.base.ICompleteListener;
import com.itboye.ihomebank.bean.HouseBean;
import com.itboye.ihomebank.bean.PersonDataBean;
import com.itboye.ihomebank.bean.ResultEntity;
import com.itboye.ihomebank.interfaces.IHouseInterface;
import com.itboye.ihomebank.interfaces.IUserInterface;
import com.itboye.ihomebank.responsitory.HouseRepository;
import com.itboye.ihomebank.responsitory.UserRepository;

/***
 * 
 * @author 递增给Responsitory
 * 
 */
public class HousePresenter extends BasePresenter implements
		IHouseInterface<HouseBean> {

	public static String houseDetail_fail = "_HouseDetail_success";
	public static String houseDetail_success = "_HouseDetail_fail";
	public static String xiaJia_fail = "_XiaJia_fail";
	public static String xiaJia_success = "_XiaJia_success";
	public static String shangJia_success = "_ShangJia_success";
	public static String shangJia_fail = "_ShangJia_fail";

	public static String woDeFangYuan_success = "_WoDeFangYuan_success";
	public static String woDeFangYuan_fail = "_WoDeFangYuan_fail";
	// 房源字典
	public static final String houseZiDian_success = "_houseZiDian_success";
	public static final String houseZiDian_fail = "_houseZiDian_fail";
	// 房源字典
	public static final String qianYueGuanLi_success = "_QianYueGuanLi_success";
	public static final String qianYueGuanLi_fail = "_QianYueGuanLi_fail";
	public static String hotTag_success="_HotTag_success";
	public static String hotTag_fail="_HotTag_success";

	public HousePresenter(Observer observer) {
		super(observer);
	}

	// 收藏
	public static final String collection_success = HousePresenter.class
			.getName() + "_Collection_success";// 由此判断请求的接口
	public static final String collection_fail = HousePresenter.class.getName()
			+ "_Collection_fail";
	// 房源查询
	public static final String queryHouse_success = HousePresenter.class
			.getName() + "_QueryHouse_success";// 由此判断请求的接口
	public static final String queryHouse_fail = HousePresenter.class.getName()
			+ "_QuryHouse_fail";

	// 房源地区查询
	public static final String queryHouseArea_success = HousePresenter.class
			.getName() + "_QueryHouseArea_success";// 由此判断请求的接口
	public static final String queryHouseArea_fail = HousePresenter.class
			.getName() + "_QuryHouseArea_fail";

	// 签约申请
	public static final String qianYueShenQing_success = HousePresenter.class
			.getName() + "_QianYueShenQing_success";// 由此判断请求的接口
	public static final String qianYueShenQing_fail = HousePresenter.class
			.getName() + "_QianYueShenQing_fail";

	// 预约看房
	public static final String yuYueKanFang_success = HousePresenter.class
			.getName() + "_YuYueKanFang_success";// 由此判断请求的接口
	public static final String yuYueKanFang_fail = HousePresenter.class
			.getName() + "_YuYueKanFang_fail";

	// 我的发布列表
	public static final String woDeFaBuList_success = HousePresenter.class
			.getName() + "_WoDeFaBuList_success";
	public static final String woDeFaBuList_fail = HousePresenter.class
			.getName() + "_WoDeFaBuList_fail";

	// 房源区域列表
	public static final String quyuLieBiao_success = HousePresenter.class
			.getName() + "_QuyuLieBiao_success";// 由此判断请求的接口
	public static final String quyuLieBiao_fail = HousePresenter.class
			.getName() + "_QuyuLieBiao_fail";

	// 房源区域列表
	public static final String quyuLieBiao02_success = HousePresenter.class
			.getName() + "_QuyuLieBiao02_success";// 由此判断请求的接口
	public static final String quyuLieBiao02_fail = HousePresenter.class
			.getName() + "_QuyuLieBiao02_fail";

	public static final String xuanZuKe_fail = "_XuanZuKe_fail";
	public static final String xuanZuKe_success = "_XuanZuKe_success";

	public static final String getZuKe_fail = "_GetZuKe_fail";
	public static final String getZuKe_success = "_GetZuKe_success";

	public static final String fangYuanRenZheng_fail = "_FangYuanRenZheng_fail";
	public static final String fangYuanRenZheng_success = "_FangYuanRenZheng_success";
	
	public static final String woDeQiuZu_fail="_woDeQiuZu_fail";
	public static final String woDeQiuZu_success="_woDeQiuZu_success";

	@Override
	public void getHouseAdd(String uid, String imgs, String community_code,
			int rent_type, String contact_name, String contact_phone, int rent,
			int size, String unit, int house_floor, int floors,
			String house_decoration, String house_pay, String house_dir,
			String address) {
		// TODO Auto-generated method stub

	}

	@Override
	public void collection(String uid, String fType, String favoriteId,
			int status) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> user = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(collection_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(collection_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		user.collection(uid, fType, favoriteId, status);
	}

	@Override
	public void queryHouse(String cityCode, String searchText,
			String areaOrZone, String rental, String aceage, String houseType,
			String rentType, String decoration, String oritation, String floor,
			String source, String houseTag, String order, String perPage,
			String currentPage) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(queryHouse_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(queryHouse_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.queryHouse(cityCode, searchText, areaOrZone, rental, aceage,
				houseType, rentType, decoration, oritation, floor, source,
				houseTag, order, perPage, currentPage);
	}

	@Override
	public void getAreaByCityCode(String cityCode) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(queryHouseArea_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(queryHouseArea_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getAreaByCityCode(cityCode);

	}

	@Override
	public void queryHouseDetail(String houseNo, String uid) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(houseDetail_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(houseDetail_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.queryHouseDetail(houseNo, uid);
	}

	@Override
	public void shenQingQianYue(String uid, String houseNo, String remark,
			String status) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(qianYueShenQing_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(qianYueShenQing_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.shenQingQianYue(uid, houseNo, remark, status);
	}

	@Override
	public void yuYueKanFang(String uid, String houseNo, String mark,
			String status, String startT, String endT) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(yuYueKanFang_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(yuYueKanFang_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.yuYueKanFang(uid, houseNo, mark, status, startT, endT);
	}

	@Override
	public void getWoDeFaBu(String uid) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(woDeFaBuList_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(woDeFaBuList_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getWoDeFaBu(uid);
	}

	@Override
	public void xiajia(String uid, String houseNo) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(xiaJia_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(xiaJia_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.xiajia(uid, houseNo);
	}

	@Override
	public void shangjia(String uid, String houseNo) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(shangJia_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(shangJia_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.shangjia(uid, houseNo);
	}

	/**
	 * 获取房源区域列表
	 */
	public void getQuyuLieBiao(String area_code) {
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(quyuLieBiao_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(quyuLieBiao_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getQuyuLieBiao(area_code);
	}

	@Override
	public void getQuyuLieBiao02(String area_code) {
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(quyuLieBiao02_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(quyuLieBiao02_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getQuyuLieBiao02(area_code);

	}

	@Override
	public void xuanZuKe(String uid,String ownerUid, String houseNo, String status) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(xuanZuKe_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(xuanZuKe_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.xuanZuKe(uid,ownerUid, houseNo, status);
	}

	@Override
	public void getZuKeList(String houseNo) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(getZuKe_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(getZuKe_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getZuKeList(houseNo);
	}

	@Override
	public void fangYuanRenZheng(String uid, String houseNo, String pass,
			String msg) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(fangYuanRenZheng_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(fangYuanRenZheng_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.fangYuanRenZheng(uid, houseNo, pass, msg);
	}

	@Override
	public void getMyRentHouse(String uid) {
		// TODO Auto-generated method stub

		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(woDeFangYuan_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(woDeFangYuan_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getMyRentHouse(uid);
	}

	/**
	 * 房源数据字典
	 */
	@Override
	public void houseZiDian(String city_code) {
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(houseZiDian_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(houseZiDian_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.houseZiDian(city_code);

	}

	@Override
	public void qianYueGuanLi(String uid, String sort) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(qianYueGuanLi_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(qianYueGuanLi_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.qianYueGuanLi(uid, sort);

	}
	
	@Override
	public void getQiuZu(String uid) {
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(woDeQiuZu_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(woDeQiuZu_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getQiuZu(uid);
		
	}
	@Override
	public void getHotTag(String cityCode) {
		// TODO Auto-generated method stub
		IHouseInterface<HouseBean> house = new HouseRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						result.setEventTag(Tag_Success);
						result.setEventType(hotTag_success);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						result.setEventTag(Tag_Error);
						result.setEventType(hotTag_fail);
						HousePresenter.this.setChanged();
						HousePresenter.this.notifyObservers(result);

					}
				});
		house.getHotTag(cityCode);
	}
}
